The basic usage of this decoder is as follows:
Note that the stream decoder has no real concept of stream position, it just converts data. To seek within a stream the callbacks have only to flush the decoder using FLAC__stream_decoder_flush() and start feeding data from the new position through the read callback. The seekable stream decoder does just this.
The FLAC__stream_decoder_set_metadata_*() functions deserve special attention. By default, the decoder only calls the metadata_callback for the STREAMINFO block. These functions allow you to tell the decoder explicitly which blocks to parse and return via the metadata_callback and/or which to skip. Use a FLAC__stream_decoder_set_metadata_respond_all(), FLAC__stream_decoder_set_metadata_ignore() ... or FLAC__stream_decoder_set_metadata_ignore_all(), FLAC__stream_decoder_set_metadata_respond() ... sequence to exactly specify which blocks to return. Remember that some metadata blocks can be big so filtering out the ones you don't use can reduce the memory requirements of the decoder. Also note the special forms FLAC__stream_decoder_set_metadata_respond_application(id) and FLAC__stream_decoder_set_metadata_ignore_application(id) for filtering APPLICATION blocks based on the application ID.
STREAMINFO and SEEKTABLE blocks are always parsed and used internally, but they still can legally be filtered from the metadata_callback.
true
, otherwise false
.
|
Signature for the read callback. See FLAC__stream_decoder_set_read_callback() for more info.
|
|
Signature for the write callback. See FLAC__stream_decoder_set_write_callback() for more info.
|
|
Signature for the metadata callback. See FLAC__stream_decoder_set_metadata_callback() for more info.
|
|
Signature for the error callback. See FLAC__stream_decoder_set_error_callback() for more info.
|
|
State values for a FLAC__StreamDecoder The decoder's state can be obtained by calling FLAC__stream_decoder_get_state().
|
|
Return values for the FLAC__StreamDecoder read callback.
|
|
Return values for the FLAC__StreamDecoder write callback. |
|
Possible values passed in to the FLAC__StreamDecoder error callback.
|
|
Create a new stream decoder instance. The instance is created with default settings; see the individual FLAC__stream_decoder_set_*() functions for each setting's default.
|
|
Free a decoder instance. Deletes the object pointed to by decoder.
|
|
Set the read callback. The supplied function will be called when the decoder needs more input data. The address of the buffer to be filled is supplied, along with the number of bytes the buffer can hold. The callback may choose to supply less data and modify the byte count but must be careful not to overflow the buffer. The callback then returns a status code chosen from FLAC__StreamDecoderReadStatus.
|
|
Set the write callback. The supplied function will be called when the decoder has decoded a single frame of data. The decoder will pass the frame metadata as well as an array of pointers (one for each channel) pointing to the decoded audio.
|
|
Set the metadata callback. The supplied function will be called when the decoder has decoded a metadata block. In a valid FLAC file there will always be one STREAMINFO block, followed by zero or more other metadata blocks. These will be supplied by the decoder in the same order as they appear in the stream and always before the first audio frame (i.e. write callback). The metadata block that is passed in must not be modified, and it doesn't live beyond the callback, so you should make a copy of it with FLAC__metadata_object_clone() if you will need it elsewhere. Since metadata blocks can potentially be large, by default the decoder only calls the metadata callback for the STREAMINFO block; you can instruct the decoder to pass or filter other blocks with FLAC__stream_decoder_set_metadata_*() calls.
|
|
Set the error callback. The supplied function will be called whenever an error occurs during decoding.
|
|
Set the client data to be passed back to callbacks. This value will be supplied to callbacks in their client_data argument.
|
|
Direct the decoder to pass on all metadata blocks of type type.
|
|
Direct the decoder to pass on all APPLICATION metadata blocks of the given id.
|
|
Direct the decoder to pass on all metadata blocks of any type.
|
|
Direct the decoder to filter out all metadata blocks of type type.
|
|
Direct the decoder to filter out all APPLICATION metadata blocks of the given id.
|
|
Direct the decoder to filter out all metadata blocks of any type.
|
|
Get the current decoder state.
|
|
Get the current number of channels in the stream being decoded. Will only be valid after decoding has started and will contain the value from the most recently decoded frame header.
|
|
Get the current channel assignment in the stream being decoded. Will only be valid after decoding has started and will contain the value from the most recently decoded frame header.
|
|
Get the current sample resolution in the stream being decoded. Will only be valid after decoding has started and will contain the value from the most recently decoded frame header.
|
|
Get the current sample rate in Hz of the stream being decoded. Will only be valid after decoding has started and will contain the value from the most recently decoded frame header.
|
|
Get the current blocksize of the stream being decoded. Will only be valid after decoding has started and will contain the value from the most recently decoded frame header.
|
|
Initialize the decoder instance. Should be called after FLAC__stream_decoder_new() and FLAC__stream_decoder_set_*() but before any of the FLAC__stream_decoder_process_*() functions. Will set and return the decoder state, which will be FLAC__STREAM_DECODER_SEARCH_FOR_METADATA if initialization succeeded.
|
|
Finish the decoding process. Flushes the decoding buffer, releases resources, resets the decoder settings to their defaults, and returns the decoder state to FLAC__STREAM_DECODER_UNINITIALIZED. In the event of a prematurely-terminated decode, it is not strictly necessary to call this immediately before FLAC__stream_decoder_delete() but it is good practice to match every FLAC__stream_decoder_init() with a FLAC__stream_decoder_finish().
|
|
Flush the stream input. The decoder's input buffer will be cleared and the state set to
|
|
Reset the decoding process. The decoder's input buffer will be cleared and the state set to
|
|
Decode one metadata block or audio frame. This version instructs the decoder to decode a either a single metadata block or a single frame and stop, unless the callbacks return a fatal error or the read callback returns As the decoder needs more input it will call the read callback. Depending on what was decoded, the metadata or write callback will be called with the decoded metadata block or audio frame, unless an error occurred. If the decoder loses sync it will call the error callback instead.
|
|
Decode until the end of the metadata. This version instructs the decoder to decode from the current position and continue until all the metadata has been read, or until the callbacks return a fatal error or the read callback returns As the decoder needs more input it will call the read callback. As each metadata block is decoded, the metadata callback will be called with the decoded metadata. If the decoder loses sync it will call the error callback.
|
|
Decode until the end of the stream. This version instructs the decoder to decode from the current position and continue until the end of stream (the read callback returns As the decoder needs more input it will call the read callback. As each metadata block and frame is decoded, the metadata or write callback will be called with the decoded metadata or frame. If the decoder loses sync it will call the error callback.
|
|
Maps a FLAC__StreamDecoderState to a C string. Using a FLAC__StreamDecoderState as the index to this array will give the string equivalent. The contents should not be modified. |
|
Maps a FLAC__StreamDecoderReadStatus to a C string. Using a FLAC__StreamDecoderReadStatus as the index to this array will give the string equivalent. The contents should not be modified. |
|
Maps a FLAC__StreamDecoderWriteStatus to a C string. Using a FLAC__StreamDecoderWriteStatus as the index to this array will give the string equivalent. The contents should not be modified. |
|
Maps a FLAC__StreamDecoderErrorStatus to a C string. Using a FLAC__StreamDecoderErrorStatus as the index to this array will give the string equivalent. The contents should not be modified. |